package taskList

import (
	"context"
	"donkey-admin/internal/dao"
)

type ClearTableTask struct {
}

// Exec @description: 清理数据库表数据
// tableName(表名) string, compareField(比较字段) string, interval(间隔) string
// @return: error
func (t ClearTableTask) Exec(ctx context.Context, arg interface{}) error {

	_, err := dao.SysOperationLog.Ctx(ctx).Where("created_at < DATE_SUB(NOW(), INTERVAL 7 DAY)").Delete()
	if err != nil {
		return err
	}

	return nil
}
